<script lang="ts" setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { showToast } from 'vant';

const router = useRouter();
const show = ref(false);
const actions = [{ name: '关闭工单' }];
const onSelect = (item: { name: string }) => {
  console.log('item=>   ', item.name);
  // 默认情况下点击选项时不会自动收起
  // 可以通过 close-on-click-action 属性开启自动收起
  show.value = false;
  showToast(item.name);
};
</script>

<template>
  <div class="header">
    <div class="header-left" @click="router.back()">
      <van-icon name="arrow-left" />
      <div class="info">1</div>
    </div>
    <div>test(6)</div>
    <van-icon name="ellipsis" @click="show = true" />
  </div>
  <!-- <van-cell is-link title="基础用法" /> -->
  <van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" />
</template>

<style scoped lang="less">
.header {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .header-left {
    display: flex;
    align-items: center;

    .van-icon-arrow-left {
      margin-left: 10px;
    }
    .info {
      font-size: 8px;
      text-align: center;
      width: 24px;
      height: 24px;
      line-height: 24px;
      background-color: #ccc;
      border-radius: 50%;
    }
  }

  .header-left > .van-icon-arrow-left,
  .van-icon-ellipsis {
    font-size: 20px;
    font-weight: bold;
    line-height: 30px;
  }

  .van-icon-ellipsis {
    margin-right: 10px;
  }
}
</style>
